{% extends 'blog/base_generic.html' %}
{% load static %}

{% block content %}

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>博客文章列表</title>
</head>

<body>
  <h1>博客文章列表</h1>

  <!-- 返回首页的链接 -->
  <p><a href="{% url 'home' %}">返回首页</a></p>

  <ul>
    {% for post in posts %}
    <li><a href="{% url 'post_detail' post.pk %}">{{ post.title }}</a></li>
    {% endfor %}
  </ul>
</body>

</html>

<div class="pagination">
  <span class="step-links">
    {% if page_obj.has_previous %}
    <a href="?page=1">&laquo; 第一页</a>
    <a href="?page={{ page_obj.previous_page_number }}">上一页</a>
    {% endif %}

    <span class="current">
      第 {{ page_obj.number }} 页，共 {{ page_obj.paginator.num_pages }} 页
    </span>

    {% if page_obj.has_next %}
    <a href="?page={{ page_obj.next_page_number }}">下一页</a>
    <a href="?page={{ page_obj.paginator.num_pages }}">最后一页 &raquo;</a>
    {% endif %}
  </span>
</div>

<a href="{% url 'post_create' %}">创建新文章</a>
{% endblock %}